<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">
    <ui:define name="head">
        <link type="text/css" href="#{request.contextPath}/UI/epss/epss.css" rel="stylesheet"/>
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
        </script>
    </ui:define>
    <ui:define name="content">
        <h:form id="form">
            <p:growl id="msgs" showDetail="false"/>
            <p:commandButton id="addBtn"
                             value="增加" icon="ui-icon-plus"
                             action="#{itemSubcttAction.selectRecordAction('Add')}"
                             update="pgView,pdt,msgs"
                             onclick="PF('wVDlgView').show()">
            </p:commandButton>
            <p:contextMenu for="pdt" id="pcm" rendered='#{itemSubcttAction.strMngNotFinishFlag}'>
                <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                            actionListener="#{itemSubcttAction.selectRecordAction('Upd')}"
                            update="pgView,pdt,msgs"
                            onclick="PF('wVDlgView').show()">
                </p:menuitem>
                <p:menuitem value="删除" icon="ui-icon-close"
                            actionListener="#{itemSubcttAction.selectRecordAction('Del')}"
                            update="pgView,pdt,msgs"
                            onclick="PF('wVDlgView').show()">
                </p:menuitem>
                <p:menuitem value="复制" icon="ui-icon-copy"
                            actionListener="#{itemSubcttAction.selectRecordAction('Copy')}"
                            update="pgView,msgs,pdt,pcm">
                </p:menuitem>
                <p:menuitem value="剪切" icon="ui-icon-scissors"
                            actionListener="#{itemSubcttAction.selectRecordAction('Cut')}"
                            update="pgView,msgs,pdt,pcm">
                </p:menuitem>
                <p:menuitem value="粘贴（同层_上）" icon="ui-icon-clipboard"
                            rendered="#{itemSubcttAction.strPasteBtnRendered}"
                            actionListener="#{itemSubcttAction.selectRecordAction('Paste_brother_up')}"
                            update="pgView,msgs,pdt,pcm">
                </p:menuitem>
                <p:menuitem value="粘贴（同层_下）" icon="ui-icon-clipboard"
                            rendered="#{itemSubcttAction.strPasteBtnRendered}"
                            actionListener="#{itemSubcttAction.selectRecordAction('Paste_brother_down')}"
                            update="pgView,msgs,pdt,pcm">
                </p:menuitem>
                <p:menuitem value="粘贴（子层）" icon="ui-icon-clipboard"
                            rendered="#{itemSubcttAction.strPasteBtnRendered}"
                            actionListener="#{itemSubcttAction.selectRecordAction('Paste_children')}"
                            update="pgView,msgs,pdt,pcm">
                </p:menuitem>
                <p:menuitem value="成本计划详细内容" icon="ui-icon-search"
                             onclick ="wvCstplDetail.show()" >
                </p:menuitem>
            </p:contextMenu>
            <p:dataTable id="pdt" style="width:100%;"
                     value="#{itemSubcttAction.itemOfEsItemHieRelapList}"
                     var="record"
                     rowKey="#{record.pkid}"
                     selection="#{itemSubcttAction.itemOfEsItemHieRelapSelected}"
                     selectionMode="single"
                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                                     {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                     paginator="true"
                     paginatorPosition="bottom"
                     rows="15"
                     rowsPerPageTemplate="500,200,100,45,30,15"
                     rowIndexVar="row"
                     emptyMessage="数据记录为空..."
                     rowStyleClass="#{record.name eq '合计'? 'rowDoneStyle': record.name eq '总合计'? 'rowDoneStyle':null}"
                     scrollable="true">
                <p:column style="width:30px" headerText="序号">
                    <h:outputText value="#{row + 1}"/>
                </p:column>
                <p:column style="width:100px" headerText="成本项号">
                    <h:outputText value="#{record.strCorrespondingItemNo}" escape="false"/>
                </p:column>
                <p:column style="width:200px" headerText="成本项名">
                    <h:outputText value="#{record.strCorrespondingItemName}"/>
                </p:column>
                <p:column style="width:100px" headerText="分包编号">
                    <h:outputText value="#{record.strNo}" escape="false"/>
                </p:column>
                <p:column style="width:200px" headerText="分包名称">
                    <h:outputText value="#{record.name}" />
                </p:column>
                <p:column style="width:60px" headerText="分包单位">
                    <h:outputText value="#{record.unit}" style="text-align:right"/>
                </p:column>
                <p:column style="width:80px" headerText="分包单价">
                    <h:outputText value="#{record.contractUnitPrice}" style="float: right" >
                        <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                    </h:outputText>
                </p:column>
                <p:column style="width:80px" headerText="分包数量">
                    <h:outputText value="#{record.contractQuantity}" style="float: right">
                        <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                    </h:outputText>
                </p:column>
                <p:column style="width:80px" headerText="分包金额">
                    <h:outputText value="#{record.contractAmount}" style="float: right">
                        <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                    </h:outputText>
                </p:column>
                <p:column style="width:100px" headerText="分包甲供材单价">
                    <h:outputText value="#{record.signPartAPrice}" style="float: right">
                        <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                    </h:outputText>
                </p:column>
                <p:column style="width:100px" headerText="分包备注">
                    <h:outputText value="#{record.note}"/>
                </p:column>
            </p:dataTable>
            <p:dialog id="dLCstplDetail" widgetVar="wvCstplDetail"  header="成本计划">
                <p:dataTable id="pdtCstpl"
                               value="#{(itemSubcttAction.itemOfEsItemHieRelapList_Cstpl)}"
                               var="recordCstpl"
                               dynamic="true"
                               selectionMode="single"
                               rowKey="#{recordCstpl.pkid}"
                               selection="#{itemSubcttAction.itemOfEsItemHieRelapSelected_Cstpl}"
                               paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                               {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                               paginator="true"
                               paginatorPosition="bottom"
                               rows="15"
                               rowsPerPageTemplate="100,50,30,20,10"
                               emptyMessage="数据记录为空..."
                               scrollable="true">
                    <p:column headerText="成本计划项编码">
                        <h:outputText value="#{recordCstpl.strNo}" escape="false"/>
                    </p:column>
                    <p:column headerText="成本计划项名称">
                        <h:outputText value="#{recordCstpl.name}" />
                    </p:column>
                    <p:column headerText="单位">
                        <h:outputText value="#{recordCstpl.unit}" style="text-align:right"/>
                    </p:column>
                    <p:column headerText="单价">
                        <h:outputText value="#{recordCstpl.contractUnitPrice}" style="float: right" >
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="合同数量">
                        <h:outputText value="#{recordCstpl.contractQuantity}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="合同金额">
                        <h:outputText value="#{recordCstpl.contractAmount}" style="float: right">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:outputText>
                    </p:column>
                    <p:column headerText="备注">
                        <h:outputText value="#{recordCstpl.note}" />
                    </p:column>
                    <f:facet name="footer">
                        <p:commandButton id="cstplSelSubmitBtn" value="提交"
                                         action="#{itemSubcttAction.submitAction_Cstpl()}"
                                         update=":form:pdt" oncomplete="wvCstplDetail.hide()"/>
                    </f:facet>
                </p:dataTable>
            </p:dialog>
            <p:dialog id="dlgView" header="分包合同内容维护" widgetVar="wVDlgView"
                      resizable="false" modal="true"
                      showEffect="clip" hideEffect="fold">
                <h:panelGrid id="pgView">
                    <h:panelGrid columns="2">
                        <p:outputLabel for="noItemHieRelap" value="项目编号：" />
                        <h:inputText id="noItemHieRelap"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.strNo}"
                                     readonly="#{itemSubcttAction.styleModelNo.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModelNo.disabled_Style};">
                            <p:ajax event="blur" update="msgs,pgOperBtn,strCorrespondingItemNo"
                                    listener="#{itemSubcttAction.blurStrNoToGradeAndOrderid()}"/>
                        </h:inputText>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <p:outputLabel for="name" value="项目名称：" />
                        <p:selectOneMenu id="name"
                                         value="#{itemSubcttAction.itemOfEsItemHieRelap.name}"
                                         editable="true"
                                         disabled="#{itemSubcttAction.styleModel.disabled_Flag}"
                                         style="#{itemSubcttAction.styleModel.disabled_Style};">
                            <f:selectItems value="#{esCommon.subcttItemNamelist}" />
                            <p:ajax update="msgs,contractQuantity,contractUnitPrice,contractAmount"
                                    listener="#{itemSubcttAction.blurStrName()}"/>
                        </p:selectOneMenu>
                        <p:outputLabel  value="*固定项输入时,选择左面下拉框中的项目*" />
                    </h:panelGrid>
                    <h:panelGrid columns="2">
                        <p:outputLabel for="strCorrespondingItemNo" value="计划项号：" />
                        <h:inputText id="strCorrespondingItemNo"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.strCorrespondingItemNo}"
                                     readonly="#{itemSubcttAction.styleModel.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModel.disabled_Style}">
                            <p:ajax event="blur" update="msgs,correspondingItemName"
                                    listener="#{itemSubcttAction.blurCorrespondingPkid}"/>
                        </h:inputText>
                        <p:outputLabel for="correspondingItemName" value="计划项名：" />
                        <h:inputText id="correspondingItemName"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.strCorrespondingItemName}"
                                     readonly="#{itemSubcttAction.styleModel.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModel.disabled_Style};width:328px;">
                        </h:inputText>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:outputLabel for="unit" value="单位："/>
                        <h:inputText id="unit"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.unit}"
                                     readonly="#{itemSubcttAction.styleModel.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModel.disabled_Style};text-align:right;"/>
                        <p:outputLabel for="contractQuantity" value="合同数量："/>
                        <h:inputText id="contractQuantity"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.contractQuantity}"
                                     readonly="#{itemSubcttAction.styleModelCttQty.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModelCttQty.disabled_Style};text-align:right;">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            <p:ajax event="blur" update="contractAmount"
                                    listener="#{itemSubcttAction.blurCalculateAmountAction}"/>
                        </h:inputText>
                        <p:outputLabel for="contractUnitPrice" value="综合单价："/>
                        <h:inputText id="contractUnitPrice"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.contractUnitPrice}"
                                     readonly="#{itemSubcttAction.styleModelCttQty.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModelCttQty.disabled_Style};text-align:right;">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                            <p:ajax event="blur" update="contractAmount"
                                    listener="#{itemSubcttAction.blurCalculateAmountAction}"/>
                        </h:inputText>
                        <p:outputLabel for="contractAmount" value="合同金额："/>
                        <h:inputText id="contractAmount"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.contractAmount}"
                                     readonly="#{itemSubcttAction.styleModelCttAmount.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModelCttAmount.disabled_Style};text-align:right;">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:inputText>
                        <p:outputLabel for="signPartAPrice" value="甲供材价："/>
                        <h:inputText id="signPartAPrice"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.signPartAPrice}"
                                     readonly="#{itemSubcttAction.styleModel.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModel.disabled_Style};text-align:right;">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0.00"/>
                        </h:inputText>
                        <p:outputLabel for="note" value="备注内容：" />
                        <h:inputText id="note"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.note}"
                                     readonly="#{itemSubcttAction.styleModel.disabled_Flag}"
                                     style="#{itemSubcttAction.styleModel.disabled_Style};text-align:left;"/>
                        <p:outputLabel for="originFlag" value="数据来源：" />
                        <h:inputText id="originFlag"
                                     value="#{esCommon.originFlagListValueOfAlias(
                                 itemSubcttAction.itemOfEsItemHieRelap.originFlag)}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="modificationNum" value="修改次数：" />
                        <h:inputText id="modificationNum"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.modificationNum}"
                                     readonly="true"
                                     style="background-color:gainsboro;text-align:right;">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0"/>
                        </h:inputText>
                        <p:outputLabel for="createdBy" value="创建人：" />
                        <h:inputText id="createdBy"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.createdByName}"
                                     readonly="true"
                                     style="background-color:gainsboro;"/>
                        <p:outputLabel for="createdDate" value="创建时间：" />
                        <h:inputText id="createdDate"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.createdDate}"
                                     readonly="true"
                                     style="background-color:gainsboro"/>
                        <p:outputLabel for="lastUpdBy" value="修改人：" />
                        <h:inputText id="lastUpdBy"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.lastUpdByName}"
                                     readonly="true"
                                     style="background-color:gainsboro"/>
                        <p:outputLabel for="lastUpdDate" value="修改时间：" />
                        <h:inputText id="lastUpdDate"
                                     value="#{itemSubcttAction.itemOfEsItemHieRelap.lastUpdDate}"
                                     readonly="true"
                                     style="background-color:gainsboro"/>
                    </h:panelGrid>
                    <h:panelGrid id="pgOperBtn" columns="4" rendered='#{itemSubcttAction.strMngNotFinishFlag}'>
                        <p:commandButton id="submitBtn"
                                         value="#{itemSubcttAction.strSubmitType eq 'Add'?'提交（增加）':
                                               itemSubcttAction.strSubmitType eq 'Upd'?'提交（更新）':
                                               itemSubcttAction.strSubmitType eq 'Del'?'提交（删除）':'提交'}"
                                         action="#{itemSubcttAction.submitThisRecordAction}"
                                         update="pgOperBtn,pdt,msgs,pcm,pgView">
                        </p:commandButton>
                        <p:commandButton id="resetBtn" value="重置"
                                         type="reset"
                                         update="pgView,pcm">
                        </p:commandButton>
                        <p:ajaxStatus style="width:16px;height:16px;">
                            <f:facet name="start">
                                <h:graphicImage value="/images/ajaxloading.gif"/>
                            </f:facet>
                            <f:facet name="complete">
                                <h:outputText value=""/>
                            </f:facet>
                        </p:ajaxStatus>
                    </h:panelGrid>
                </h:panelGrid>
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>